package com.wpzf.ndhc.service.impl;

import com.wpzf.common.core.utils.ServletUtils;
import com.wpzf.common.security.service.TokenService;
import com.wpzf.ndhc.mapper.WpzfNdhcHcdwMapper;
import com.wpzf.ndhc.service.WpzfNdhcCommonService;
import com.wpzf.ndhc.service.WpzfNdhcHcdwService;
import com.wpzf.ndhc.utils.TableUtil;
import com.wpzf.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class WpzfNdhcHcdwServiceImpl implements WpzfNdhcHcdwService {

    @Autowired
    WpzfNdhcHcdwMapper wpzfNdhcHcdwMapper;

    @Autowired
    WpzfNdhcCommonService wpzfNdhcCommonService;

    @Autowired
    TokenService tokenService;

    @Override
    public List<Map<String, Object>> query_unit_w_task(Map<String, Object> parm) {  /*获取未完成任务列表*/
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_unit_w_task(parm);
    }

    @Override
    public Integer query_unit_w_task_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_unit_w_task_count(parm);
    }

    @Override
    public List<Map<String, Object>> query_wwc_Provs(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_wwc_Provs(parm);
    }

    @Override
    public List<Map<String, Object>> query_wwc_Citys(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_wwc_Citys(parm);
    }

    @Override
    public List<Map<String, Object>> query_unit_w_task_list(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_unit_w_task_list(parm);
    }

    @Override
    public List<Map<String, Object>> query_unit_wtask_list(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_unit_wtask_list(parm);
    }

    @Override
    public List<Map<String, Object>> query_unit_y_task(Map<String, Object> parm) {  /*获取已完成任务列表*/
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_unit_y_task(parm);
    }

    @Override
    public Integer query_unit_y_task_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_unit_y_task_count(parm);
    }

    @Override
    public List<Map<String, Object>> query_ywc_Provs(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_ywc_Provs(parm);
    }

    @Override
    public List<Map<String, Object>> query_ywc_Citys(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_ywc_Citys(parm);
    }

    @Override
    public List<Map<String, Object>> query_unit_y_task_list(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_unit_y_task_list(parm);
    }

    @Override
    public List<Map<String, Object>> query_unit_ytask_list(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_unit_ytask_list(parm);
    }

    /*提交核查结果*/
    @Override
    public Integer updateSubmit(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.updateSubmit(parm);
    }

    @Override
    public Integer tbhcjgSubmit(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.tbhcjgSubmit(parm);
    }

    @Override
    public Integer getTBCount(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.getTBCount(parm);
    }  /*查询当前行政区已核查的图斑数量*/

    @Override
    public List<Map<String, Object>> get_unit_user_y_static(Map<String, Object> parm) {  /*获取当前用户所有已完成的任务*/
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_user_y_static(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_user_w_static(Map<String, Object> parm) {  /*获取当前用户所有未完成的任务*/
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_user_w_static(parm);
    }

    @Override
    public Integer get_unit_user_w_static_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_user_w_static_count(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_dqr_static(Map<String, Object> parm) {  /*<!--获取当前用户所有待确认任务-->*/
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_dqr_static(parm);
    }

    @Override
    public Integer get_unit_dqr_static_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_dqr_static_count(parm);
    }

    @Override
    public List<Map<String, Object>> queryProvs(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.queryProvs(parm);
    }

    @Override
    public List<Map<String, Object>> queryCitys(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.queryCitys(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_dqr_static_list(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_dqr_static_list(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_yqr_static(Map<String, Object> parm) {  /*获取当前用户所有已确认任务*/
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_yqr_static(parm);
    }

    @Override
    public Integer get_unit_yqr_static_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_yqr_static_count(parm);
    }

    @Override
    public List<Map<String, Object>> query_yqr_Provs(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_yqr_Provs(parm);
    }

    @Override
    public List<Map<String, Object>> query_yqr_Citys(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.query_yqr_Citys(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_yqr_static_list(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_yqr_static_list(parm);
    }

    @Override
    public Integer getTbhcjglist(Map<String, Object> parm) {  /*获取当前用户所有未完成的任务*/
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.getTbhcjglist(parm);
    }

    @Override
    public List<Map<String, Object>> get_usertask_static(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.get_usertask_static(parm);
    }

    @Override
    public Integer get_usertask_static_count(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.get_usertask_static_count(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_pchlist(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.get_unit_pchlist(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_tasklist(Map<String, Object> parm) {
        //parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_tasklist(parm);
    }

    @Override
    public Integer get_unit_tasklist_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_tasklist_count(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_prov(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.get_unit_prov(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_city(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.get_unit_city(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_wfp_tasklist(Map<String, Object> parm) {
//        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_wfp_tasklist(parm);
    }

    @Override
    public Integer get_unit_wfp_tasklist_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_wfp_tasklist_count(parm);
    }

    @Override
    public int add_pf_user(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.add_pf_user(parm);
    }

    @Override
    public int update_pf_user(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.update_pf_user(parm);
    }

    @Override
    public List<Map<String, Object>> get_dwhcrw_pf(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_dwhcrw_pf(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_static_user(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.get_unit_static_user(parm);
    }

    @Override
    public Integer get_unit_static_user_count(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.get_unit_static_user_count(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_static(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.get_unit_static(param);
    }

    @Override
    public Integer get_unit_static_count(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.get_unit_static_count(param);
    }

    @Override
    public int add_unit_user(Map<String, Object> parm) {
        //parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.add_unit_user(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_tbbhlist(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_tbbhlist(parm);
    }

    @Override
    public Integer get_unit_tbbhlist_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_tbbhlist_count(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_not_confirmtbbhlist(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_not_confirmtbbhlist(parm);
    }

    @Override
    public Integer get_unit_not_confirmtbbhlist_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_not_confirmtbbhlist_count(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_confirmtbbhlist(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_confirmtbbhlist(parm);
    }

    @Override
    public Integer get_unit_confirmtbbhlist_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_confirmtbbhlist_count(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_yfp_tasklist(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_yfp_tasklist(parm);
    }

    @Override
    public List<Map<String, Object>> get_unit_yfp_wz_tasklist(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_yfp_wz_tasklist(parm);
    }

    @Override
    public Integer get_unit_yfp_wz_tasklist_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_yfp_wz_tasklist_count(parm);
    }

    @Override
    public List<Map<String, Object>> getJlhcjgqrSheng(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.getJlhcjgqrSheng(parm);
    }

    @Override
    public List<Map<String, Object>> getJlhcjgqrXian(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.getJlhcjgqrXian(parm);
    }

    @Override
    public List<Map<String, Object>> getJlhcjgqrLeftList(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.getJlhcjgqrLeftList(parm);
    }

    @Override
    public List<Map<String, Object>> dwUnitLeaderLeftList(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.dwUnitLeaderLeftList(parm);
    }

    @Override
    public List<Map<String, Object>> getWjXxTqjgByWjmc(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.getWjXxTqjgByWjmc(parm);
    }

    @Override
    public Integer get_unit_user_y_static_count(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.get_unit_user_y_static_count(parm);
    }

    @Override
    public Integer fpdw(Map<String, Object> parm) {
        Integer rest = 0;
        //查询需要进行分配的单位
        List<Map<String, Object>> fpdwList = wpzfNdhcHcdwMapper.queryFpdw(parm);
        int dwSize = fpdwList.size();
        //查询当前批次所有的行政区
        List<Map<String, Object>> fpXzqList = wpzfNdhcHcdwMapper.queryFpXzq(parm);
        //查询当前批次已经进行分配的单位
        List<Map<String, Object>> hcrwfpdwList = wpzfNdhcHcdwMapper.queryHcrwfpdw(parm);

        int index = 0;

        //判断当前批次是否有分配过单位
        if (hcrwfpdwList != null && hcrwfpdwList.size() > 0) {
            return -1;
        } else {
            for (Map<String, Object> fpXzq : fpXzqList) {
                Map<String, Object> fpdw = fpdwList.get(index);

                String xzqh = (fpXzq.get("xzqdm") + "").substring(0, 2);

                int nextIndex = index;
//                while (xzqh.equals(fpdw.get("xzqh") + "")) {
                    // 找到下一个合适的人员
//                    nextIndex = (nextIndex + 1) % dwSize;
//                    fpdw = fpdwList.get(index);
//                }

                //保存到单位分配表
                fpXzq.put("nd", "2024");
                fpXzq.put("dwmc", fpdw.get("dwmc"));
                fpXzq.put("pch", parm.get("pch"));
                fpXzq.put("fpsj", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime()));

                rest += wpzfNdhcHcdwMapper.saveHcrwfpdw(fpXzq);

                index = (nextIndex + 1) % dwSize; // 更新索引，如果到达最后一个人，则从第一个人重新开始

            }
        }
        return rest;
    }

    @Override
    public List<Map<String, Object>> queryFpdwPch(Map<String, Object> parm) {
        parm = TableUtil.TableName(parm);
        return wpzfNdhcHcdwMapper.queryFpdwPch(parm);
    }

    @Override
    public List<Map<String, Object>> queryHcrwfpdw(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.queryHcrwfpdw(parm);
    }

    @Override
    public Integer queryHcrwfpdwCount(Map<String, Object> parm) {
        return wpzfNdhcHcdwMapper.queryHcrwfpdwCount(parm);
    }


    @Override
    public List<Map<String, Object>> getPch(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.getPch(param);
    }

    @Override
    public List<Map<String, Object>> getSheng(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.getSheng(param);
    }

    @Override
    public List<Map<String, Object>> getXian(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.getXian(param);
    }

    @Override
    public List<Map<String, Object>> queryXzqTask(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryXzqTask(param);
    }

    @Override
    public Integer queryXzqTaskCount(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryXzqTaskCount(param);
    }

    @Override
    public List<Map<String, Object>> queryDkTask(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryDkTask(param);
    }

    @Override
    public Integer queryDkTaskCount(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryDkTaskCount(param);
    }

    @Override
    public List<Map<String, Object>> queryDkTaskByIndex(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryDkTaskByIndex(param);
    }

    @Override
    public List<Map<String, Object>> getDkList(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.getDkList(param);
    }

    @Override
    @Transactional
    public Integer submitdate(List<Map<String, Object>> params) {
        Integer rest = 0;
        if (params != null && params.size() > 0) {
            Map<String, Object> map = new HashMap<>();
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            map.put("user_name", loginUser.getUsername());
            map.put("nick_name", loginUser.getSysUser().getNickName());
            map.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
            for (Map<String, Object> param : params) {
                map.put("xzqdm", param.get("xzqdm"));
                map.put("pch", param.get("pch"));
                map.put("ywhj", "0");
                map.put("sftj", "是");
                map.put("sftj_submitdate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime()));

                Integer i = wpzfNdhcHcdwMapper.updateSubmit(map);
                rest += i;
                if (i > 0) {
                    wpzfNdhcHcdwMapper.tbhcjgSubmit(map);
                    List<Map<String, Object>> dkList = wpzfNdhcHcdwMapper.getDkList(map);
                    if (dkList != null && dkList.size() > 0) {
                        for (Map<String, Object> dk : dkList) {
                            map.put("dkbsm", dk.get("bsm") + "");
                            map.put("dkbh", dk.get("dkbh") + "");
                            map.put("xzqdm", map.get("xzqdm") + "");
                            map.put("pch", dk.get("pch") + "");
                            wpzfNdhcHcdwMapper.deleteHcrwfpjlByDk(map);
                            //查看该监理任务是否属于扣除类
                            List<Map<String, Object>> kc = wpzfNdhcHcdwMapper.queryHcrwkc(map);
                            if (kc != null && kc.size() > 0) {
                                map.put("jl_sfkc", "1"); //属于扣除类

                                //添加到审核表
                                Map<String, Object> tbhcjgsm = wpzfNdhcCommonService.getHcjgsmByDkbh(map);
                                map.put("hcjgsm", tbhcjgsm != null && tbhcjgsm.get("hcjgsm") != null ? tbhcjgsm.get("hcjgsm") : null);
                                map.put("submitdate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime()));
                                wpzfNdhcHcdwMapper.deleteShTb(map);
                                wpzfNdhcHcdwMapper.saveShTb(map);
                            } else {
                                map.put("jl_sfkc", "0");
                            }
                            wpzfNdhcHcdwMapper.saveHcrwfpjl(map); //添加监理任务
                        }
                    }
                }
            }
        }
        return rest;
    }

    @Override
    public List<Map<String, Object>> getBatchNumberList(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.getBatchNumberList(param);
    }

    @Override
    public List<Map<String, Object>> getProvinceList(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.getProvinceList(param);
    }

    @Override
    public List<Map<String, Object>> getCountyList(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.getCountyList(param);
    }

    @Override
    public List<Map<String, Object>> queryDkTaskList(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryDkTaskList(param);
    }

    @Override
    public Integer queryDkTaskListCount(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryDkTaskListCount(param);
    }

    @Override
    public List<Map<String, Object>> queryDkTaskListByIndex(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryDkTaskListByIndex(param);
    }

    @Override
    public List<Map<String, Object>> queryQrDkTask(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryQrDkTask(param);
    }

    @Override
    public Integer queryQrDkTaskCount(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryQrDkTaskCount(param);
    }

    @Override
    public List<Map<String, Object>> queryQrDkTaskByIndex(Map<String, Object> param) {
        return wpzfNdhcHcdwMapper.queryQrDkTaskByIndex(param);
    }

    @Override
    @Transactional
    public Integer jlhcjgqrSubmit(List<Map<String, Object>> params) {
        Integer rest = 0;
        if (params != null && params.size() > 0) {
            Map<String, Object> map = new HashMap<>();
            LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
            map.put("user_name", loginUser.getSysUser().getUserName());
            map.put("nick_name", loginUser.getSysUser().getNickName());
            map.put("dwmc", loginUser.getSysUser().getDept().getDeptName());
            for (Map<String, Object> param : params) {
                map.put("dkbsm", param.get("dkbsm"));
                map.put("dkbh", param.get("dkbh"));
                map.put("xzqdm", param.get("xzqdm"));
                map.put("pch", param.get("pch"));
                map.put("ywhj", "2");
                map.put("sftj", "是");
                map.put("sftj_submitdate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime()));

                Integer i = wpzfNdhcHcdwMapper.tbhcjgSubmit(map);
                rest += i;
                if (i > 0) {
                    Map<String, Object> tbhcjg = wpzfNdhcHcdwMapper.queryTbhcjg(map);
                    String jljgqr = tbhcjg.get("jl_jljgqr") + "";
                    if ("同意".equals(jljgqr)) {
                        map.put("ywhj", "1");
                    } else if ("不同意".equals(jljgqr)) {
                        map.put("ywhj", "0");
                    }
                    map.put("jl_jljgqr", jljgqr);
                    Map<String, Object> tbhcjgsm = wpzfNdhcCommonService.getHcjgsmByDkbh(map);
                    map.put("hcjgsm", tbhcjgsm != null && tbhcjgsm.get("hcjgsm") != null ? tbhcjgsm.get("hcjgsm") : null);
                    map.put("submitdate", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((new Date()).getTime()));
                    wpzfNdhcHcdwMapper.deleteShTb(map);
                    wpzfNdhcHcdwMapper.saveShTb(map);
                }
            }
        }
        return rest;
    }

}
